﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MSTestContrib.Specifications;
using System.Xml;

namespace GoGrid.Specifications
{
    [TestClass]
    [SpecificationDescription("BillingSummary contains up to date billing information for GoGrid usage.")]
    public class BillingSummarySpecification : GoGridSpecificationBase
    {
        [TestMethod]
        [ScenarioDescription("BillingSummaryCreateFromXmlNode method correctly transforms sample XML fragment from Wiki site to object.")]
        [DeploymentItem("SampleData\\BillingSummarySample.xml")]
        public void BillingSummaryCreateFromXmlNodeMethodCorrectlyTransformsSampleXmlFragmentFromWikiSiteToObject()
        {
            Given("a fragment of XML from the GoGrid wiki site", x => x.State.Fragment = LoadXmlFragment(x, "BillingSummarySample.xml"))
                .When("the CreateFromXmlNode method is called", x => x.State.BillingSummary = BillingSummary.CreateFromXmlNode(x.State.Fragment, null))
                .Then("the StateDate should equal midnight on July 12th, 2008 (PDT)", x => x.State.BillingSummary.StartDate == "Sat Jul 12 00:00:00 PDT 2008")
                .And("the EndDate should equal midnight on August 12th, 2008 (PDT)", x => x.State.BillingSummary.EndDate == "Tue Aug 12 00:00:00 PDT 2008")
                .And("the memory allotment should equal 0", x => x.State.BillingSummary.MemoryAllotment == 0)
                .And("the memory in use should equal 0.5", x => x.State.BillingSummary.MemoryInUse == 0.5m)
                .And("the memory accrued should equal 192", x => x.State.BillingSummary.MemoryAccrued == 192)
                .And("the memory overage should equal 52", x => x.State.BillingSummary.MemoryOverage == 52)
                .And("the memory overage charge should equal 9.879999876022339", x => x.State.BillingSummary.MemoryOverageCharge == 9.879999876022339m)
                .And("the transfer allotment should equal 0", x => x.State.BillingSummary.TransferAllotment == 0)
                .And("the transfer accrued should equal 0", x => x.State.BillingSummary.TransferAccrued == 0)
                .And("the transfer overage should equal 0", x => x.State.BillingSummary.TransferOverage == 0)
                .And("the transfer overage charge should equal 0", x => x.State.BillingSummary.TransferOverageCharge == 0);
        }
    }
}
